package com.yang.pojo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import javax.annotation.Resource;

//@Autowired:默认byType，如果无法匹配，则再匹配byName，否则最后多个id可以指定name值
//@Resource:先匹配byName,后byType,有一个匹配就自动装配,否则最后多个id可以指定name值
public class People {
    //显示的 required = false，表明此属性可以为null
    //@Autowired(required = false)
    @Autowired
    private Cat cat;

//    @Autowired
//    @Qualifier("dog1")
    @Resource(name = "dog1")
    private Dog dog;
    private String name;

    public Cat getCat() {
        return cat;
    }

    public void setCat(Cat cat) {
        this.cat = cat;
    }

    public Dog getDog() {
        return dog;
    }

    public void setDog(Dog dog) {
        this.dog = dog;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "People{" +
                "name='" + name + '\'' +
                ", cat=" + cat +
                ", dog=" + dog +
                '}';
    }
}
